package com.example.logintest1.controller;

import com.example.logintest1.Entry.AdminMember;
import com.example.logintest1.Entry.AdminMemberDTO;
import com.example.logintest1.Entry.ResponseResult;
import com.example.logintest1.mapper.AdminMemberMapper;
import com.example.logintest1.serviceimpl.LoginServcie;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
//@RequestMapping("/user")
public class LoginController {

    @Resource
    private LoginServcie loginServcie;
    @Resource
    AdminMemberMapper adminMemberMapper;
    @RequestMapping("/user/login")
    public ResponseResult login(@RequestBody AdminMember adminMember){
//        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
//
//        // 要加密的密码
//        String rawPassword = adminMember.getPas();
//
//        // 使用BCryptPasswordEncoder加密密码
//        String encodedPassword = passwordEncoder.encode(rawPassword);
//        adminMember.setPas(encodedPassword);
////         将用户信息存入数据库
//        adminMemberMapper.insert(adminMember);
//        // 输出加密后的密码
//        System.out.println("Encoded Password: " + encodedPassword);
        return loginServcie.login(adminMember);
    }

//    @RequestMapping("/logout")
//    public ResponseResult logout(){
//        return loginServcie.logout();
//    }
}